#include <DmxSimple.h>

int DMX_dir = 4;

void setup(){
  Serial.begin(9600);
   pinMode(DMX_dir, OUTPUT);    
  
  digitalWrite(DMX_dir, HIGH);  // Set direction pin of trasnsceiver to Tx.
  
  /* The most common pin for DMX output is pin 3, which DmxSimple
  ** uses by default. If you need to change that, do it here. */
  DmxSimple.usePin(2);
  
  //DmxSimple.maxChannel(50);
}

int channel = 0;


void loop(){
      if (Serial.available() > 0 && Serial.read() != -1 ){
        if (channel != 0) DmxSimple.write(channel, 0);
        channel++;
        if (channel >= 40) channel=1;
        Serial.print("channel:");
        Serial.println(channel);
        DmxSimple.write(channel, 255);
      }
      Serial.flush();
      delay(30);
      Serial.flush();
  
      //DmxSimple.write(patch[i], ledPower); 
}
